package com.talking.adapter

import android.annotation.SuppressLint
import android.app.Activity
import android.view.View
import android.view.ViewGroup
import android.widget.ArrayAdapter
import com.bumptech.glide.Glide
import com.talking.R
import com.talking.bean.UserBean
import com.talking.databinding.ItemSearchBinding
import com.talking.util.Network
import com.talking.util.Tools

class SearchAdapter(private val activity: Activity, objects: List<UserBean?>) : ArrayAdapter<UserBean?>(activity, 0, objects){
    override fun getView(position: Int, convertView: View?, parent: ViewGroup): View {
        @SuppressLint("ViewHolder") val binding = ItemSearchBinding.inflate(activity.layoutInflater)
        val bean = getItem(position)
        Glide.with(activity).load(Network.BASE_URL+bean!!.iconUrl).apply(Tools.getGlideOption()).placeholder(R.drawable.loading).placeholder(R.drawable.loading).error(R.drawable.loaderr).into(binding.itemSearchIcon)
       binding.itemSearchMail.text= bean.mail
       binding.itemSearchNickname.text= bean.nickname
        return binding.root
    }
}